import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** IP地址信息 */
export interface Ipv4Addresses {
          ipv4AddressId: number; // ID
          ipv4Address?: string; // IPv4 地址
          ipv4Prefixlen?: number; // 子网掩码
          ipv4NetworkId?: string; // 子网的网络地址
          portId?: number; // 端口ID
          contextName: string; // SNMP 上下文名称
  }

// IP地址 API
export const Ipv4AddressesApi = {
  // 查询IP地址分页
  getIpv4AddressesPage: async (params: any) => {
    return await request.get({ url: `/business/ipv4-addresses/page`, params })
  },

  // 查询IP地址详情
  getIpv4Addresses: async (id: number) => {
    return await request.get({ url: `/business/ipv4-addresses/get?id=` + id })
  },

  // 新增IP地址
  createIpv4Addresses: async (data: Ipv4Addresses) => {
    return await request.post({ url: `/business/ipv4-addresses/create`, data })
  },

  // 修改IP地址
  updateIpv4Addresses: async (data: Ipv4Addresses) => {
    return await request.put({ url: `/business/ipv4-addresses/update`, data })
  },

  // 删除IP地址
  deleteIpv4Addresses: async (id: number) => {
    return await request.delete({ url: `/business/ipv4-addresses/delete?id=` + id })
  },

  /** 批量删除IP地址 */
  deleteIpv4AddressesList: async (ids: number[]) => {
    return await request.delete({ url: `/business/ipv4-addresses/delete-list?ids=${ids.join(',')}` })
  },

  // 导出IP地址 Excel
  exportIpv4Addresses: async (params) => {
    return await request.download({ url: `/business/ipv4-addresses/export-excel`, params })
  },
}
